/*
 * Timeset.h
 *
 *  Created on: 27.07.2012
 *      Author: maikel
 */

#ifndef TIMESET_H_
#define TIMESET_H_

#include <string>
#include <vector>
#include <istream>

#include "Atom.h"

using std::string;
using std::vector;
using std::istream;
using Eigen::Vector3d;

namespace gro {

struct Timeset {
	friend istream &operator>>(istream &, Timeset &);

	double time;
	string title;
	vector<Atom> atoms;
	double box[3][3];

	// Exceptions
	class exception {
	public:
		exception() {}
		exception(string w): w(w) { }
		const char *what() { return w.c_str(); }

	private:
		string w;
	};

	class NoTime : public exception {
	public:
		NoTime(string line): line(line) {
			exception("No time giving in title line: '" + line + "'");
		}
	private:
		string line;
	};
	enum Parsing { atom_count, atom, box_vector };

	class ParseError : public exception {
	public:

		ParseError(Parsing p): p(p) {
			switch (p) {
			case atom_count:
				exception("An error occurred while parsing the count of atoms.");
				break;
			case atom:
				exception("An error occurred while parsing an atom line.");
				break;
			case box_vector:
				exception("An error occured while parsing the box vectors.");
				break;
			}
		}
		Parsing when() { return p; }
	private:
		Parsing p;
	};
};

} /* namespace gro */
#endif /* TIMESET_H_ */
